using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.IO;

namespace CodePlex.EnterpriseFramework
{
    public class Common
    {
        public static Stream XmlTransform(string xslPath, XmlReader input)
        {
            // Load the style sheet.
            XslCompiledTransform xslt = new XslCompiledTransform();
            xslt.Load(xslPath);
            
            XPathDocument xpathDoc = new XPathDocument(input);
            while (input.Read()) { };

            Stream result = new MemoryStream();
            // using makes sure that we flush the writer at the end
            xslt.Transform(xpathDoc, null, result);

            return result;
        }
    }
}
